﻿using System.Data.Entity.ModelConfiguration;
using OneBlog.Model.Entities;

namespace OneBlog.DataAccessLayer.ModelConfigurations
{
    public class BlogUserMap:EntityTypeConfiguration<BlogUser>
    {
        public BlogUserMap()
        {
            ToTable("BlogUser");
            Property(c => c.UserName).HasMaxLength(40).IsRequired();
            Property(c => c.Password).HasMaxLength(40).IsRequired();
            Property(c => c.NickName).HasMaxLength(20).IsRequired();
            Property(c => c.Email).HasMaxLength(20).IsRequired();
            Property(c => c.Photo).HasMaxLength(100);

            HasMany(c => c.BlogInfos).WithRequired(c => c.CreateUser).HasForeignKey(c=>c.UserId);
            HasMany(c => c.BlogComments).WithRequired(c => c.User).HasForeignKey(c => c.UserId);
            HasMany(c => c.BlogTypes).WithRequired(c => c.CreateUser).HasForeignKey(c => c.UserId);
        }
    }
}